package linuxbox.util;

import java.util.*;

public class CommonUtil {
    public static void erraseCommon(List list1, List list2) {
        print("in CommonUtil.erraseCommon ... ");
        print(list1);
        print(list2);
	    for (Iterator it1 = list1.iterator(); it1.hasNext(); ) {
	        Integer id1 = (Integer)it1.next();
    	    for (Iterator it2 = list2.iterator(); it2.hasNext(); ) {
    	        Integer id2 = (Integer)it2.next();
                if (id1.intValue() == id2.intValue()) {
                    it1.remove();
                    it2.remove();
                }
            }
        }
    }
    
    public static void main(String[] args) {
        List list1 = new ArrayList();
        list1.add(new Integer(2));                         
        list1.add(new Integer(3));                         
        list1.add(new Integer(4));                         
        list1.add(new Integer(5));                         

        List list2 = new ArrayList();
        list2.add(new Integer(1));                         
        list2.add(new Integer(3));                         
        list2.add(new Integer(4));                         
        list2.add(new Integer(7));
        
        erraseCommon(list1, list2);
        print(list1);
        print(list2);
    }
    
    public static void print(Object obj) {
        System.out.println(obj);
    }
}